<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue.set 全局操作</title>
</head>
<body>
<h1>Vue.set 全局操作</h1>
<hr>
<div id="app">
    {{count}}
    <div>
        <li v-for="item in arr">{{item}}</li>
    </div>
</div>
<button onclick="add()">点击增加</button>
<script src="../assets/js/vue.js"></script>
<script>
    function add() {
//        Vue.set(OutData,'count',2);
//        app.count++;
//        OutData.count++;
//        app.arr[2]='ddd';   //上行代码注释后本代码不执行
        Vue.set(app.arr, 2, 'ddddd');
    }
    var OutData = {
        count: 1,
//        name:'honoryao'
        arr: ['aaa', 'bbb', 'ccc']
    };
    var app = new Vue({
        el: '#app',
        data: OutData
    });
</script>
</body>
</html>